package springbootorderrabbitmqproducer.demo.config;

import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @ClassName MessageConfirmCallback
 * @Date 2021/6/9 0009 下午 14:24
 * @Author Administrator
 * @Description TODO
 * Version 1.0
 * 消息确认配置
 */
@Component
public class MessageConfirmCallback implements RabbitTemplate.ConfirmCallback,RabbitTemplate.ReturnsCallback {

   @Autowired
   private RabbitTemplate rabbitTemplate;

   @PostConstruct
   public void initRabbitTemplate(){
       rabbitTemplate.setConfirmCallback(this::confirm);
       rabbitTemplate.setReturnCallback(this::returnedMessage);
   }

    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {

    }

    @Override
    public void returnedMessage(ReturnedMessage returned) {

    }
}
